package com.linux.huhx.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @Author: huhx
 * @Date: 2017-12-15 上午 9:51
 * @Desc: 定义一个aspect
 */

@Aspect
public class NotVeryUsefulAspect {
    private static final String pointCutString = "execution(* com.linux.huhx.business.service.MyAspectService1.*())";

    @Before(pointCutString)
    public void beforeExecute() {
        System.out.println("before advice.");
    }

    @After(pointCutString)
    public void afterExecute() {
        System.out.println("after advice.");
    }

    @AfterReturning(value = pointCutString, returning = "retVal")
    public void afterReturingExecute1(String retVal) {
        System.out.println("after throwing " + retVal);
    }

    @AfterThrowing(value = pointCutString, throwing = "exception")
    public void afterThrowingExecute1(Throwable exception) {
        System.out.println("throwing in advice show message: " + exception.getMessage());
    }

    @Around(value = pointCutString)
    public void arundExecute1(ProceedingJoinPoint pjp) throws Throwable{
        System.out.println("before around.");
        System.out.println(pjp.proceed());
        System.out.println("after around.");
    }
}
